package com.edu;

import com.edu.commons.filter.CrossFilter;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@MapperScan(basePackages = "com.edu.mapper")
public class GraduateApp {
    public static void main(String[] args) {
        SpringApplication.run(GraduateApp.class,args);
    }


    @Bean
    public FilterRegistrationBean<CrossFilter> crossDomainFilter(){
        FilterRegistrationBean<CrossFilter> registrationBean =
                new FilterRegistrationBean<>();
        //web.xml中的filter
        registrationBean.setFilter(new CrossFilter());

        //web.xml 中的url-pattern
        registrationBean.addUrlPatterns("/*");
        return registrationBean;
    }
}
